#include <iostream>
#include <ctime>

#define N 10

using namespace std;

void insertionsort(int a[N]);

int main ( )
{
    int a[N],i;
    srand((unsigned int)time(0));

    for(i=0;i<N;i++)
    {
        a[i]=rand()%100;
        cout<<a[i]<<" ";
    }
    cout<<endl;

    insertionsort(a);

    for(i=0;i<N;i++)
    {
        cout<<a[i]<<"  ";

    }

    cin>>i;
    return 0;
}

void insertionsort(int a[N])
{
    int i,j,t;
    
    for(i=1;i<N;i++)
    {
        t=a[i];
        j=i-1;

        while(t<a[j])
        {
            a[j+1]=a[j];
            j--;
            if(j==-1) break;
        }

        a[j+1]=t;
    }
}
